package com.yidu.InventoryManagement.mapper;

import com.yidu.BusinessData.entity.Security;
import com.yidu.InventoryManagement.entity.Fund;
import com.yidu.InventoryManagement.entity.SecurityAccrualStock;

import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

/**
 * @author z
 * @version 1.0
 * @date 2022/12/6
 */
@Mapper
public interface SecurityAccrualStockMapper {



    @Select("select count(*) from securityAccrualStock")
    public int selectSecurityAccrualStockId();

    /**
     * 查询
     * @return 返回一个集合
     */
    @Select("select * from securityAccrualStock where 1=1 ${strWhere} limit #{page},#{limit}")
    List<SecurityAccrualStock> selectSecuritiesInventory(Map map);

    /**
     * 分页查询
     * @param map 结果集
     * @return 根据条件查询
     */
    @Select("select count(*) from securityAccrualStock where 1=1 ${strWhere}")
    int selectSecuritiesInventoryInfo(Map map);

    //新增
    @Insert("INSERT INTO securityAccrualStock VALUES (#{securityAccrualStockId},#{date},#{fundId},#{securityId},#{securityType},#{businessState},#{money},#{initialState},#{remark})")
    public int addSecuritiesInventoryInfo(SecurityAccrualStock securityAccrualStock);

    @Select("select max(securityAccrualStockId) from securityAccrualStock")
    String getmaxsecurityAccrualStockId();
    //修改
    //  DATE fundId securityId securityType businessState money
    //fundId securityId securityType businessState money date
    @Update("update securityAccrualStock set date=#{date},fundId=#{fundId},securityId=#{securityId},securityType=#{securityType},businessState=#{businessState},money=#{money} where securityAccrualStockId=#{securityAccrualStockId}")
    public int updateSecuritiesInventoryInfo(SecurityAccrualStock securityAccrualStock);
    //删除通过id删除
    public int deleteSecuritiesInventoryInfo(List securityAccrualStockId);



    /**
     * 下拉表格的查询基金信息
     * @return list 集合
     */
    @Select("select * from fund where 1=1 ${term} limit #{page},#{limit};")
    public List<Fund> selectFundIdAndFundName(Map map);

    /**
     * 下拉表格查询基金信息的行数
     */
    @Select("select count(*) from fund where 1=1 ${term}")
    public int selectFundIdAndFundNameCount(Map map);
    /**
     * 下拉表格的查询证券信息
     * @return list 集合
     */
    @Select("select * from security where 1=1 ${term} limit #{page},#{limit};")
    public List<Security>selectSecurityIdAndSelectSecurityName(Map map);

    /**
     * 下拉表格查询证券信息的行数
     */
    @Select("select count(*) from security where 1=1 ${term}")
    public int selectSecurityIdAndSelectSecurityNameCount(Map map);
}
